﻿@{
    ViewData["Title"] = "登录";
    ViewData["PageWithoutContainer"] = "true";
    ViewData["PageWithoutHeader"] = "true";
    ViewData["PageWithoutSidebar"] = "true";
    ViewData["BodyClass"] = "pace-top";
}
@section Styles {
}
@section Scripts {
    <script src="~/plugins/parsleyjs/dist/parsley.min.js"></script>
    <script src="~/plugins/parsleyjs/dist/i18n/zh_cn.extra.js"></script>
    <script src="~/plugins/parsleyjs/dist/i18n/zh_cn.js"></script>
    <script>
        
        var login = function () {
            if (!$('#form-login').parsley().validate()) return;
            $.ajax({
                type: "POST",
                dataType: "json",
                //contentType: "application/json; charset=UTF-8",
                url: "@Url.Action("Index", "Login")",
                data: $("#form-login").serialize(),
                success: function (result) {
                    if (result.Success) {
                        window.location.href = "@Url.Action("Index", "Home")";
                    } else {
                        show_alert('warning', result.Message)
                    }
                },
                error: function (e) {
                    show_alert('error', '网络异常.')
                }
            });
        }
        $(document).ready(function () {
            $("#form-login-button").click(function () {
                login();
            });
            $('input[name="Password"]').keydown(function (event) {
                if (event.keyCode == 13) {
                    login();
                }
            });
        });

    </script>
}
<!-- begin login -->
<div class="login login-v1">
    <!-- begin login-container -->
    <div class="login-container">
        <!-- begin login-header -->
        <div class="login-header">
            <div class="brand">
                <span class="logo">
                    <span class="text-blue">内</span>
                    <span class="text-red">部</span>
                    <span class="text-orange">系</span>
                    <span class="text-blue">统</span>
                </span> <b>登录</b>
                <small>...</small>
            </div>
            <div class="icon">
                <i class="fa fa-lock"></i>
            </div>
        </div>
        <!-- end login-header -->
        <!-- begin login-body -->
        <div class="login-body">
            <!-- begin login-content -->
            <div class="login-content">
                <form id="form-login" asp-action="Index" class="margin-bottom-0">
                    <div class="form-group m-b-20">
                        <input type="text" name="UserName" class="form-control form-control-lg inverse-mode" placeholder="用户名" data-parsley-required="true" data-parsley-minlength="3" />
                        <!--data-parsley-required-message="确认密码不可为空"-->
                    </div>
                    <div class="form-group m-b-20">
                        <input type="password" name="Password" class="form-control form-control-lg inverse-mode" placeholder="密码" data-parsley-required="true" data-parsley-minlength="6" />
                    </div>
                    <div class="login-buttons">
                        <input id="form-login-button" type="button" class="btn btn-primary btn-block btn-lg" value="登录" />
                    </div>
                </form>
            </div>
            <!-- end login-content -->
        </div>
        <!-- end login-body -->
    </div>
    <!-- end login-container -->
</div>
<!-- end login -->
